package com.hall.items.dto;

import java.util.ArrayList;
import java.util.List;

import com.hall.items.aggr.MyEquipType;
import com.hall.items.aggr.MyPlayerWeaponPack;
import com.hall.items.aggr.MyWeapon;

import dml.game.weapon.aggr.EquipedWeapon;

/**
 * springdatamongodb会自动把map里int的key转为String,所以需要此DTO
 *
 */
public class MyPlayerWeaponPackDTO {

	private long id;

	private long userId;

	private int packNum;

	private boolean currentPack;

	private List<EquipedWeapon<MyEquipType, MyWeapon>> equipItems = new ArrayList<>();

	public MyPlayerWeaponPackDTO() {
	}

	public MyPlayerWeaponPackDTO(MyPlayerWeaponPack entity) {
		id = (long) entity.getId();
		userId = (long) entity.getPlayerId();
		packNum = entity.getPackNum();
		currentPack = entity.isCurrentPack();
		for (EquipedWeapon<MyEquipType, MyWeapon> item : entity
				.getEquipedWeapons().getWeapons().values()) {
			equipItems.add(item);
		}
	}

	public MyPlayerWeaponPack toEntity() {
		MyPlayerWeaponPack entity = new MyPlayerWeaponPack();
		entity.setId(id);
		entity.setPlayerId(userId);
		entity.setPackNum(packNum);
		entity.setCurrentPack(currentPack);
		for (EquipedWeapon<MyEquipType, MyWeapon> item : equipItems) {
			if (item != null) {
				entity.getEquipedWeapons().put(item.getWeaponEquipType(), item);
			}
		}
		return entity;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getUserId() {
		return userId;
	}

	public void setUserId(long userId) {
		this.userId = userId;
	}

	public int getPackNum() {
		return packNum;
	}

	public void setPackNum(int packNum) {
		this.packNum = packNum;
	}

	public boolean isCurrentPack() {
		return currentPack;
	}

	public void setCurrentPack(boolean currentPack) {
		this.currentPack = currentPack;
	}

	public List<EquipedWeapon<MyEquipType, MyWeapon>> getEquipItems() {
		return equipItems;
	}

	public void setEquipItems(
			List<EquipedWeapon<MyEquipType, MyWeapon>> equipItems) {
		this.equipItems = equipItems;
	}

}
